package com.xx.util;

public class FormatFileSizeUtil {
	public static String formatFileSize(String strFileSize)

	{
	  long fileSize = Long.parseLong(strFileSize);
	  String showSize = "";
	  
	  if(fileSize>=0 && fileSize<1024)

	  {
	   showSize = strFileSize + "B";
	  }
	  else if(fileSize>=1024 && fileSize<(1024*1024))

	 {
	   showSize = Long.toString(fileSize/1024) + "KB";
	  }
	  else if(fileSize>=(1024*1024) && fileSize<(1024*1024*1024))

	 {
	   showSize = Long.toString(fileSize/(1024*1024)) + "MB";
	  }
	  else if(fileSize>=(1024*1024*1024))

	 {
	   showSize = Long.toString(fileSize/(1024*1024*1024)) + "GB";
	  } 
	  return showSize;
	 }
	
	
	public static void main(String[] args) {
		String size = formatFileSize("3333333");
	}
}
